/*
 * BinaryHeap.h
 *
 *  Created on: 2013-1-23
 *      Author: Administrator
 */

#ifndef BINARYHEAP_H_
#define BINARYHEAP_H_
#include <vector>

class BinaryHeap
{
public:
	explicit BinaryHeap(int capacity = 100);
	explicit BinaryHeap(const std::vector<int> &items);
	~BinaryHeap();

	bool isEmpty() const;
	const int findMin() const;
	void print() const;

	void insert(int x);
	int deleteMin();
	void makeEmpty();

private:
	unsigned _currentSize;	//The size of binary heap
	std::vector<int> _array;	//_array[0] is reserved

	void buildHeap();	//build a binary heap from any vector of _array
	void percDown(unsigned hole);
};

#endif /* BINARYHEAP_H_ */
